import easygui as g
import random
question = {}
answer = {}
index = 1
score = 0
with open('wenti.txt', 'r',encoding='utf-8') as f:
    s = f.read().split('\n')
for i in range(0,4*12,4):
    num,qus = s[i].split('、')
    question[num] = {'问题':qus,'选项':[s[i+1],s[i+2],s[i+3]]}
for i in range(4*12,4*12+5*8,5):
    num,qus = s[i].split('、')
    question[num] = {'问题':qus,'选项':[s[i+1],s[i+2],s[i+3],s[i+4]]}
with open('答案.txt', 'r') as f:
    s = f.read().split('\n')
for line in s:
    num,ans = line.split(' ')
    question[num]['答案'] = ans
for i in range(1,11):
    num = str(random.randint(1,20))
    t = g.buttonbox(question[num]['问题'],'第%d题'%i,choices=question[num]['选项'])
    if t[0]==question[num]['答案']:
        score += 10
        g.msgbox('答对了~')
    else:
        g.msgbox('答错了~正确答案是：%s'%question[num]['答案'])
    #print(question[num]['问题'],question[num]['选项'],question[num]['答案'])
g.msgbox("您得了%d分，太厉害了"%score)